package com.groupbuying.customer.controller;

import com.groupbuying.customer.service.CustomerInfoService;
import com.groupbuying.customer.service.CustomerMainService;
import com.groupbuying.customer.utils.apiresult.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api("用户信息接口")
@RestController
@RequestMapping()
public class CustomerInfoController {

    @Autowired
    private CustomerInfoService customerInfoService;

    @Autowired
    private CustomerMainService customerMainService;

    /**
     * @api {post} /customer/getCustomerInfo 获取用户信息
     * @apiExample
     * author zml
     * tar 用于客户端小程序调用
     * date 2019-10-25
     * @apiGroup CustomerProducer
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} null 无
     * @apiSuccess {Integer} code 请求结果 0-失败 1-成功
     * @apiSuccess {String} customerId 用户标示
     * @apiSuccess {BigDecimal} currencyNumber 可用积分
     * @apiSuccess {String} isCurrencyPayWord 是否设置了积分支付密码 0-否  1-是
     * @apiSuccess {String} mobile 会员手机号
     * @apiSuccess {String} gymobile 够样会员手机号，用于判断是否绑定了够样账号
     * @apiSuccess {String} nickName 会员昵称
     * @apiSuccess {Double} accountBalance 会员够样余额
     */
    @PostMapping("/getCustomerInfo")
    public ApiResult getCustomerInfo(@RequestParam Map<String, Object> params) {
        return customerInfoService.getUserInfo(params);
    }

    @GetMapping("/getCustomer")
    public ApiResult getCustomer(@RequestParam("customerId") String customerId) {
        return customerInfoService.getCustomer(customerId);
    }

    @ApiOperation(value = "重置用户登录密码", notes = "重置用户登录密码")
    @PostMapping("/resetCustomerPassword")
    public ApiResult resetCustomerPassword(@RequestParam Map<String, Object> params) {
        return customerMainService.reSetLoginPassword(params);
    }

}
